```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java线程死锁问题深度解析 | 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #111;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e45e2 0%, #89d4cf 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .code-block {
            background-color: #2d2d2d;
            border-left: 4px solid #6e45e2;
        }
        .highlight {
            position: relative;
        }
        .highlight:after {
            content: '';
            position: absolute;
            bottom: -2px;
            left: 0;
            width: 100%;
            height: 10px;
            background: rgba(110, 69, 226, 0.2);
            z-index: -1;
            transition: all 0.2s ease;
        }
        .highlight:hover:after {
            height: 16px;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">Java线程<span class="highlight">死锁问题</span>深度解析</h1>
            <p class="text-xl md:text-2xl opacity-90 mb-8 max-w-3xl mx-auto">当线程像早高峰般堵死，CPU却在疯狂飙升 - 一个生产事故的全流程复盘</p>
            <div class="flex justify-center space-x-4">
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full flex items-center">
                    <i class="fas fa-bug mr-2"></i> 生产环境问题
                </span>
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full flex items-center">
                    <i class="fas fa-microscope mr-2"></i> 深度分析
                </span>
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full flex items-center">
                    <i class="fas fa-lightbulb mr-2"></i> 解决方案
                </span>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
        <!-- Introduction -->
        <div class="mb-16">
            <p class="text-lg text-gray-700 leading-relaxed">
                上周生产环境报警群炸了——CPU使用率飙到98%！当我打开线程dump一看，二十几个线程都在<code class="bg-gray-100 px-2 py-1 rounded">BLOCKED</code>状态，像极了早高峰的三环路。这时候老板冲过来问："不是说死锁会卡死线程吗？怎么CPU还这么高？"
            </p>
        </div>

        <div class="grid md:grid-cols-3 gap-8 mb-16">
            <div class="md:col-span-2">
                <!-- Section 1 -->
                <section class="mb-16">
                    <h2 class="text-3xl font-bold mb-6 flex items-center">
                        <span class="w-8 h-8 bg-purple-600 text-white rounded-full flex items-center justify-center mr-3">1</span>
                        为什么线程会"卡死"？
                    </h2>
                    
                    <div class="mb-8">
                        <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1743219124011-1c76071f-718c-4477-875e-de882ee8cf95.png" alt="线程阻塞示意图" class="rounded-lg shadow-md w-full h-auto">
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-purple-700">死锁的四个必要条件（交通堵塞版）：</h3>
                    <div class="grid gap-4 mb-6">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-purple-100 text-purple-700 flex items-center justify-center mr-3 mt-1">1</div>
                            <p class="text-gray-700">互斥条件：单行道只能过一辆车（资源独占）</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-purple-100 text-purple-700 flex items-center justify-center mr-3 mt-1">2</div>
                            <p class="text-gray-700">请求与保持：占着左转道还想直行（持有资源不释放）</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-purple-100 text-purple-700 flex items-center justify-center mr-3 mt-1">3</div>
                            <p class="text-gray-700">不可剥夺：没有交警强制移车（系统不能回收资源）</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-purple-100 text-purple-700 flex items-center justify-center mr-3 mt-1">4</div>
                            <p class="text-gray-700">循环等待：四辆车十字路口互不相让（环形依赖）</p>
                        </div>
                    </div>
                    
                    <div class="code-block rounded-lg p-4 text-gray-200 mb-6 overflow-x-auto">
                        <pre><code class="language-java">// 经典转账死锁案例
public void transfer(Account from, Account to, int amount) {
    synchronized (from) {          // 锁住转出账户
        Thread.sleep(100);        // 模拟网络延迟
        synchronized (to) {       // 尝试锁住转入账户
            from.withdraw(amount);
            to.deposit(amount);
        }
    }
}
// 当两个线程互相转账时就会死锁</code></pre>
                    </div>
                </section>

                <!-- Section 2 -->
                <section class="mb-16">
                    <h2 class="text-3xl font-bold mb-6 flex items-center">
                        <span class="w-8 h-8 bg-purple-600 text-white rounded-full flex items-center justify-center mr-3">2</span>
                        死锁到底会不会拉高CPU？
                    </h2>
                    <h3 class="text-xl font-semibold mb-4 text-gray-700">纯死锁不会！但是...</h3>
                    <p class="text-gray-700 mb-6">
                        当线程进入<code class="bg-gray-100 px-1 py-0.5 rounded">BLOCKED</code>状态时，会主动让出CPU时间片。这时候CPU应该很闲才对，就像堵车时司机都熄火等待。但实际情况往往更复杂：
                    </p>
                    
                    <div class="mb-8">
                        <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1743219268972-a364569f-ce95-4119-ba98-cdd92d58ce91.png" alt="CPU升高原因" class="rounded-lg shadow-md w-full h-auto">
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-purple-700">CPU升高的三大间接原因：</h3>
                    <div class="grid gap-6 md:grid-cols-3 mb-8">
                        <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                            <div class="text-purple-600 text-3xl mb-3">
                                <i class="fas fa-users"></i>
                            </div>
                            <h4 class="font-bold mb-2">线程池的报复性补偿</h4>
                            <p class="text-gray-600 text-sm">大量线程被阻塞，线程池疯狂创建新线程</p>
                        </div>
                        <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                            <div class="text-purple-600 text-3xl mb-3">
                                <i class="fas fa-spinner"></i>
                            </div>
                            <h4 class="font-bold mb-2">自旋锁的忙等待</h4>
                            <p class="text-gray-600 text-sm">某些锁实现会循环尝试获取锁（CAS操作）</p>
                        </div>
                        <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                            <div class="text-purple-600 text-3xl mb-3">
                                <i class="fas fa-heartbeat"></i>
                            </div>
                            <h4 class="font-bold mb-2">监控系统的自救行为</h4>
                            <p class="text-gray-600 text-sm">健康检查、日志打印等补偿机制</p>
                        </div>
                    </div>
                    
                    <p class="text-gray-700 mb-6">
                        最近处理的一个真实案例：某支付系统死锁后，线程池从50线程暴涨到500线程，导致CPU飙升。用<code class="bg-gray-100 px-1 py-0.5 rounded">jstack</code>抓取线程快照发现，大量线程卡在<code class="bg-gray-100 px-1 py-0.5 rounded">ThreadPoolExecutor$Worker.run()</code>中的<code class="bg-gray-100 px-1 py-0.5 rounded">getTask()</code>调用。
                    </p>
                </section>

                <!-- Section 3 -->
                <section class="mb-16">
                    <h2 class="text-3xl font-bold mb-6 flex items-center">
                        <span class="w-8 h-8 bg-purple-600 text-white rounded-full flex items-center justify-center mr-3">3</span>
                        线程的六种状态
                    </h2>
                    <p class="text-gray-700 mb-6">
                        通过<code class="bg-gray-100 px-1 py-0.5 rounded">jstack</code>输出的线程状态，就能看穿JVM的内心戏：
                    </p>
                    
                    <div class="mb-8">
                        <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1743219382598-22a8a8b1-5a83-4fb2-bc8d-9ed7a9d104f6.png" alt="线程状态图" class="rounded-lg shadow-md w-full h-auto">
                    </div>
                    
                    <div class="overflow-x-auto mb-8">
                        <table class="min-w-full bg-white rounded-lg overflow-hidden">
                            <thead class="bg-purple-600 text-white">
                                <tr>
                                    <th class="py-3 px-4 text-left">状态</th>
                                    <th class="py-3 px-4 text-left">解释</th>
                                    <th class="py-3 px-4 text-left">CPU占用</th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-200">
                                <tr>
                                    <td class="py-3 px-4 font-mono">RUNNABLE</td>
                                    <td class="py-3 px-4">正在执行或等待CPU时间片</td>
                                    <td class="py-3 px-4 text-red-500 font-medium">高</td>
                                </tr>
                                <tr class="bg-gray-50">
                                    <td class="py-3 px-4 font-mono">BLOCKED</td>
                                    <td class="py-3 px-4">等待监视器锁（synchronized）</td>
                                    <td class="py-3 px-4">无</td>
                                </tr>
                                <tr>
                                    <td class="py-3 px-4 font-mono">WAITING</td>
                                    <td class="py-3 px-4">无时限等待（Object.wait()）</td>
                                    <td class="py-3 px-4">无</td>
                                </tr>
                                <tr class="bg-gray-50">
                                    <td class="py-3 px-4 font-mono">TIMED_WAITING</td>
                                    <td class="py-3 px-4">有时限等待（Thread.sleep()）</td>
                                    <td class="py-3 px-4">无</td>
                                </tr>
                                <tr>
                                    <td class="py-3 px-4 font-mono">TERMINATED</td>
                                    <td class="py-3 px-4">已终止</td>
                                    <td class="py-3 px-4">无</td>
                                </tr>
                                <tr class="bg-gray-50">
                                    <td class="py-3 px-4 font-mono">NEW</td>
                                    <td class="py-3 px-4">未启动</td>
                                    <td class="py-3 px-4">无</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-purple-700">诊断死锁的黄金命令：</h3>
                    <div class="code-block rounded-lg p-4 text-gray-200 mb-6 overflow-x-auto">
                        <pre><code class="language-bash"># 生成线程dump
jstack <pid> > thread_dump.log

# 查找死锁关键词
grep -A 20 "deadlock" thread_dump.log</code></pre>
                    </div>
                </section>
            </div>

            <!-- Sidebar -->
            <div class="md:col-span-1">
                <div class="sticky top-8">
                    <div class="bg-white p-6 rounded-xl shadow-md mb-6">
                        <h3 class="font-bold text-lg mb-4 flex items-center">
                            <i class="fas fa-bookmark text-purple-600 mr-2"></i> 目录导航
                        </h3>
                        <ul class="space-y-2">
                            <li><a href="#section1" class="text-gray-700 hover:text-purple-600 transition">1. 为什么线程会"卡死"？</a></li>
                            <li><a href="#section2" class="text-gray-700 hover:text-purple-600 transition">2. 死锁到底会不会拉高CPU？</a></li>
                            <li><a href="#section3" class="text-gray-700 hover:text-purple-600 transition">3. 线程的六种状态</a></li>
                            <li><a href="#section4" class="text-gray-700 hover:text-purple-600 transition">4. CPU飙升时的破解指南</a></li>
                            <li><a href="#section5" class="text-gray-700 hover:text-purple-600 transition">5. 预防死锁的六个狠招</a></li>
                            <li><a href="#section6" class="text-gray-700 hover:text-purple-600 transition">6. 一个真实案例全流程复盘</a></li>
                        </ul>
                    </div>
                    
                    <div class="bg-white p-6 rounded-xl shadow-md">
                        <h3 class="font-bold text-lg mb-4 flex items-center">
                            <i class="fas fa-exclamation-triangle text-yellow-500 mr-2"></i> 关键要点
                        </h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                                <span>死锁满足四个必要条件，缺一不可</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                                <span>纯死锁不会导致CPU飙升，但间接影响会</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                                <span>使用Arthas或jstack快速定位问题</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                                <span>锁排序和tryLock是有效的预防手段</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <!-- Section 4 -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-6 flex items-center">
                <span class="w-8 h-8 bg-purple-600 text-white rounded-full flex items-center justify-center mr-3">4</span>
                CPU飙升时的破解指南
            </h2>
            
            <div class="grid md:grid-cols-3 gap-6 mb-8">
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mr-4">
                            <i class="fas fa-terminal text-purple-600 text-xl"></i>
                        </div>
                        <h3 class="font-bold text-lg">Arthas</h3>
                    </div>
                    <div class="code-block rounded-lg p-4 text-gray-200 mb-4 overflow-x-auto">
                        <pre><code class="language-bash"># 监控线程状态
thread -n 5

# 查看死锁
thread -b</code></pre>
                    </div>
                    <a href="https://arthas.aliyun.com/" class="text-purple-600 hover:text-purple-800 text-sm flex items-center">
                        了解更多 <i class="fas fa-external-link-alt ml-1 text-xs"></i>
                    </a>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                            <i class="fas fa-chart-line text-blue-600 text-xl"></i>
                        </div>
                        <h3 class="font-bold text-lg">VisualVM</h3>
                    </div>
                    <div class="mb-4">
                        <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1743218782882-bb2a1b24-63e2-4999-b8e3-4d44ae664251.png" alt="VisualVM截图" class="rounded-lg w-full h-auto">
                    </div>
                    <p class="text-gray-600 text-sm">图形化监控线程状态和CPU使用情况</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-green-100 rounded-full flex items-center justify-center mr-4">
                            <i class="fas fa-code text-green-600 text-xl"></i>
                        </div>
                        <h3 class="font-bold text-lg">压箱底的脚本</h3>
                    </div>
                    <div class="code-block rounded-lg p-4 text-gray-200 overflow-x-auto">
                        <pre><code class="language-bash">#!/bin/bash
# 监控CPU与线程数
while true; do
    date +"%T"
    top -bn1 | grep java
    jstack <pid> | grep -E "BLOCKED|RUNNABLE" | wc -l
    sleep 2
done</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 5 -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-6 flex items-center">
                <span class="w-8 h-8 bg-purple-600 text-white rounded-full flex items-center justify-center mr-3">5</span>
                预防死锁的六个狠招
            </h2>
            
            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div>
                    <h3 class="text-xl font-semibold mb-4 text-purple-700 flex items-center">
                        <i class="fas fa-sort-numeric-down-alt mr-2"></i> 1. 锁排序法
                    </h3>
                    <div class="code-block rounded-lg p-4 text-gray-200 mb-6 overflow-x-auto">
                        <pre><code class="language-java">public void transfer(Account a, Account b, int amount) {
    Account first = a.id < b.id ? a : b;
    Account second = a.id < b.id ? b : a;
    
    synchronized (first) {
        synchronized (second) {
            // 转账逻辑
        }
    }
}</code></pre>
                    </div>
                </div>
                
                <div>
                    <h3 class="text-xl font-semibold mb-4 text-purple-700 flex items-center">
                        <i class="fas fa-unlock-alt mr-2"></i> 2. 使用tryLock
                    </h3>
                    <div class="code-block rounded-lg p-4 text-gray-200 mb-6 overflow-x-auto">
                        <pre><code class="language-java">Lock lock1 = new ReentrantLock();
Lock lock2 = new ReentrantLock();

if (lock1.tryLock(1, TimeUnit.SECONDS)) {
    try {
        if (lock2.tryLock(1, TimeUnit.SECONDS)) {
            try {
                // 业务逻辑
            } finally {
                lock2.unlock();
            }
        }
    } finally {
        lock1.unlock();
    }
}</code></pre>
                    </div>
                </div>
            </div>
            
            <h3 class="text-xl font-semibold mb-4 text-purple-700">3. 其他必杀技</h3>
            <div class="grid gap-4 md:grid-cols-2">
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-6 w-6 rounded-full bg-purple-100 text-purple-700 flex items-center justify-center mr-3 mt-1">
                        <i class="fas fa-clock text-xs"></i>
                    </div>
                    <p class="text-gray-700">设置合理的锁超时时间</p>
                </div>
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-6 w-6 rounded-full bg-purple-100 text-purple-700 flex items-center justify-center mr-3 mt-1">
                        <i class="fas fa-exchange-alt text-xs"></i>
                    </div>
                    <p class="text-gray-700">避免在持锁时调用外部服务</p>
                </div>
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-6 w-6 rounded-full bg-purple-100 text-purple-700 flex items-center justify-center mr-3 mt-1">
                        <i class="fas fa-layer-group text-xs"></i>
                    </div>
                    <p class="text-gray-700">使用并发集合代替同步块</p>
                </div>
                <div class="flex items-start">
                    <div class="flex-shrink-0 h-6 w-6 rounded-full bg-purple-100 text-purple-700 flex items-center justify-center mr-3 mt-1">
                        <i class="fas fa-search text-xs"></i>
                    </div>
                    <p class="text-gray-700">定期执行死锁检测脚本</p>
                </div>
            </div>
        </section>

        <!-- Section 6 -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-6 flex items-center">
                <span class="w-8 h-8 bg-purple-600 text-white rounded-full flex items-center justify-center mr-3">6</span>
                一个真实案例全流程复盘
            </h2>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <h3 class="text-xl font-semibold mb-4 text-purple-700">背景：</h3>
                    <p class="text-gray-700 mb-6">某电商平台大促期间，订单服务CPU持续95%+，但TPS为0。</p>
                    
                    <h3 class="text-xl font-semibold mb-4 text-purple-700">排查过程：</h3>
                    <ol class="list-decimal pl-6 space-y-2 text-gray-700 mb-6">
                        <li><code class="bg-gray-100 px-1 py-0.5 rounded">top -Hp &lt;pid&gt;</code>找到高CPU线程ID</li>
                        <li>将线程ID转十六进制：<code class="bg-gray-100 px-1 py-0.5 rounded">printf "%x" 114514</code></li>
                        <li><code class="bg-gray-100 px-1 py-0.5 rounded">jstack &lt;pid&gt; | grep -A 30 0x1bf52</code></li>
                        <li>发现多个线程BLOCKED在同一个锁上</li>
                        <li>检查代码发现嵌套的synchronized块</li>
                        <li>使用ReentrantLock改写并增加tryLock</li>
                    </ol>
                    
                    <h3 class="text-xl font-semibold mb-4 text-purple-700">优化效果：</h3>
                    <div class="grid md:grid-cols-3 gap-4">
                        <div class="bg-purple-50 p-4 rounded-lg">
                            <div class="text-purple-700 font-bold text-2xl mb-1">95% → 35%</div>
                            <div class="text-gray-600 text-sm">CPU使用率降低</div>
                        </div>
                        <div class="bg-purple-50 p-4 rounded-lg">
                            <div class="text-purple-700 font-bold text-2xl mb-1">0 → 1200/s</div>
                            <div class="text-gray-600 text-sm">TPS恢复</div>
                        </div>
                        <div class="bg-purple-50 p-4 rounded-lg">
                            <div class="text-purple-700 font-bold text-2xl mb-1">30s → 200ms</div>
                            <div class="text-gray-600 text-sm">99%响应时间</div>
                        </div>
                    </div>
                </div>
                
                <div class="bg-gray-50 px-6 py-4 border-t border-gray-200">
                    <div class="flex items-center">
                        <div class="flex-shrink-0">
                            <i class="fas fa-lightbulb text-yellow-500"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-sm text-gray-600">经验总结：死锁问题往往不是独立存在的，需要结合线程池策略、系统监控等多方面排查</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-6">线程状态关系图</h2>
            <div class="bg-white p-6 rounded-xl shadow-md">
                <div class="mermaid">
                    stateDiagram-v2
                    [*] --> NEW
                    NEW --> RUNNABLE: start()
                    RUNNABLE --> BLOCKED: 等待synchronized锁
                    BLOCKED --> RUNNABLE: 获取到锁
                    RUNNABLE --> WAITING: wait()
                    WAITING --> RUNNABLE: notify()
                    RUNNABLE --> TIMED_WAITING: sleep(ms)
                    TIMED_WAITING --> RUNNABLE: 超时
                    RUNNABLE --> TERMINATED: 运行结束
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-lg font-medium text-white">技术小馆</h3>
                    <p class="mt-1 text-sm">深入探索技术奥秘，分享实战经验</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-white hover:text-purple-300 transition duration-150 ease-in-out flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i> 访问技术小馆
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```